<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
	<style>
		div{padding:100px;}
	</style>
</head>
<body>
<button id="btn1">按钮</button>
<script>
window.onload = function () {
	var oBtn = document.getElementById("btn1");
	//绑定事件
	myAddEvent(oBtn,'click',function () {
	  alert(1);
	})

  /*document.onclick =function (ev) {
      var oEvent = ev || event;

      //取消冒泡
      oEvent.cancelBubble = true;

      //阻止事件默认行为
      return false;
  }*/

}
function myAddEvent(obj,ev,fn) {
  if(obj.attachEvent){
  	obj.attachEvent('on'+ev,fn);
  }else{
  	obj.addEventListener(ev,fn,false);
  }
}
</script>
</body>
</html>